package com.ecoolex.hotel.saas.api.graphql;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.lang.NonNull;

import com.ecoolex.framework.common.enums.ResultCode;
import com.ecoolex.framework.common.util.Assert;
import com.ecoolex.framework.common.util.Check;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module;
import com.ecoolex.framework.web.api.graphql2.annotation.QueryField;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module.Type;
import com.ecoolex.hotel.saas.entity.StoreWeixinConfig;
import com.ecoolex.hotel.saas.ws.StoreService;

@GraphQL2Module(type = Type.User, description = "商户微信配置")
public class StoreWeixinConfigGraphql {

	@Reference
	private StoreService service;
	
	@QueryField(field =  "storeWeixinConfig", description = "商户微信AppId")
	public String get(@NonNull Integer storeId) {
		StoreWeixinConfig config = service.getStoreWeixinConfig(storeId);
		Assert.isTrue(Check.notNull(config),ResultCode.VERIFY.build(1), "商户微信配置不存在");
		return config.getAppId();
	}
}
